package crm.implementor;

import crm.daoInterfaces.PriorityDao;
import crm.dbhandelling.Crude;
import crm.dto.Priority;


public class PriorityImp extends Crude implements PriorityDao {

	private String className = new Priority().getClass().getName();
	@Override
	public void add(Priority priority) throws Exception 
	{
		super.insert(priority);
		
	}

	@Override
	public void update(Priority priority) 
	{
		super.update(className, "status", priority.getStatus()+"", "priorityName", priority.getPriorityName());
		
	}

	@Override
	public void delete(Priority priority) 
	{
		super.delete(className, "priorityName", priority.getPriorityName());
		
	}

	

	@Override
	public Priority[] retrieveAll() throws Exception 
	{
		Object[] att=super.retreiveAll(className);
		Priority[] p=new Priority[att.length];
		for(int i=0;i<p.length;i++)
			p[i]=(Priority) att[i];
	return p;
		
	}

	@Override
	public Priority retrieve( String conditionField,
			String conditionValue) throws Exception 
	{
		Priority p=(Priority) super.retreive(className, conditionField, conditionValue);
		return p;
	}

	@Override
	public Priority[] retrieveArray( String conditionField,
			String conditionValue) throws Exception
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		Priority[] s=new Priority[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(Priority) att[i];
		return s;
		
	}

}
